package br.com.trimark.dao;

import java.util.Collection;
import java.util.List;

import org.hibernate.Criteria;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;

import br.com.caelum.vraptor.ioc.Component;
import br.com.trimark.dao.generic.impl.GenericHibernateDAOImpl;
import br.com.trimark.dao.impl.IHotsiteDao;
import br.com.trimark.pojo.Hotsite;
import br.com.trimark.utils.exception.DataException;

@Component
public class HotsiteDao extends GenericHibernateDAOImpl<Hotsite> implements IHotsiteDao {

	private static final long serialVersionUID = -1424143354847786814L;
	
	@Override
	public List<Hotsite> findByExample(Hotsite pojo) throws DataException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Hotsite save(Hotsite pojo) throws DataException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Hotsite saveOrUpdate(Hotsite pojo) throws DataException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Hotsite update(Hotsite pojo) throws DataException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Hotsite merge(Hotsite pojo) throws DataException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public void delete(Hotsite pojo) throws DataException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void deleteAll(Collection<Hotsite> pojos) throws DataException {
		// TODO Auto-generated method stub
		
	}

	@Override
	public DetachedCriteria createDetachedCriteria(Hotsite pojo) {
		// TODO Auto-generated method stub
		return null;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Hotsite buscarPerfil(String url) throws DataException {
		
		Criteria criteria = createCriteria();
		criteria.add(Restrictions.eq("urlHotsite", url));
		
		List<Hotsite> resultList = criteria.list();
		Hotsite h = null;
		
		if (resultList.get(0) != null) {
			h = resultList.get(0);
		}
		
		return h;
	}

	@SuppressWarnings("unchecked")
	@Override
	public Hotsite buscarPerfilByUsuario(Integer codUsuario) throws DataException {
		
		Hotsite h = null;

		Criteria criteria = createCriteria();
		criteria.add(Restrictions.eq("codUsuario", codUsuario));
		
		List<Hotsite> resultList = criteria.list();
		if (resultList.get(0) != null) {
			h = resultList.get(0);
		}
		
		return h;
	}
	
}
